import React from 'react';
import classNames from 'classnames';

export enum ButtonSize {
    Large = 'lg',
    Small = 'sm'
}

export enum ButtonType {
    Primary = 'primary',
    Default = 'default',
    Danger = 'danger',
    Warning = 'warning',
    Success = 'success'
}

interface BaseButtonProps {
    className?: string,
    disabled?: boolean,
    size?: ButtonSize,
    btnType?: ButtonType,
    children: React.ReactNode
}

type NativeButtonProps = BaseButtonProps & React.ButtonHTMLAttributes<HTMLElement>;

const Button: React.FC<NativeButtonProps> = (props) => {

    const { className, btnType, disabled, size, children, ...restProps } = props;

    const classes = classNames('yulang-btn', className, {
        [`yulang-btn-${btnType}`]: btnType,
        [`yulang-btn-${size}`]: size,
        'disabled': disabled
    })

    return <button className={classes} disabled={disabled} {...restProps}>{children}</button>
}

Button.defaultProps = {
    btnType: ButtonType.Default,
    disabled: false
}
export default Button;